Skip to content

fix(billing): use active/trialing status allowlist in requireQuota middleware#3280

Merged
PierreBrisorgueil merged 2 commits into
masterfrom
fix/billing-quota-status-allowlist
Mar 19, 2026
Merged

fix(billing): use active/trialing status allowlist in requireQuota middleware#3280
PierreBrisorgueil merged 2 commits into
masterfrom
fix/billing-quota-status-allowlist

Conversation

@PierreBrisorgueil

Copy link
Copy Markdown
Contributor

Summary

  • Replace past_due-only check in requireQuota middleware with an ['active', 'trialing'] allowlist, so that canceled, unpaid, incomplete, and paused subscriptions correctly fall back to the free plan
  • Add 4 new unit tests covering canceled, unpaid, incomplete (treated as free) and trialing (uses subscription plan)

Test plan

  • All 14 unit tests pass (billing.quota.unit.tests.js)
  • Lint passes with no errors

Closes #3279

Copilot AI review requested due to automatic review settings March 19, 2026 08:44
@coderabbitai

coderabbitai Bot commented Mar 19, 2026

Copy link
Copy Markdown

Warning

Rate limit exceeded

@PierreBrisorgueil has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 15 minutes and 29 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: b7e8a6bc-85ef-4ea1-b4c5-5a2e00db1301

📥 Commits

Reviewing files that changed from the base of the PR and between 0c2efb2 and 81b4a39.

📒 Files selected for processing (4)
  • modules/billing/controllers/billing.controller.js
  • modules/billing/lib/constants.js
  • modules/billing/middlewares/billing.requireQuota.js
  • modules/billing/tests/billing.quota.unit.tests.js
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/billing-quota-status-allowlist
📝 Coding Plan
  • Generate coding plan for human review comments

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates the billing quota enforcement middleware so only active and trialing subscriptions are treated as paid for quota purposes, aligning quota gating with the billing usage endpoint and ensuring inactive subscription statuses fall back to the free plan.

Changes:

  • Replace the past_due-only check with an ['active', 'trialing'] allowlist in requireQuota.
  • Add unit tests for canceled, unpaid, incomplete (free fallback) and trialing (paid plan).

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
modules/billing/middlewares/billing.requireQuota.js Switches plan selection to an active/trialing allowlist so inactive statuses use free quotas.
modules/billing/tests/billing.quota.unit.tests.js Adds targeted unit tests to validate behavior for additional subscription statuses.

Comment thread modules/billing/middlewares/billing.requireQuota.js
Comment thread modules/billing/tests/billing.quota.unit.tests.js Outdated
…nactive statuses

- Hoist activeStatuses to shared lib/constants.js to avoid duplication
  between requireQuota middleware and billing controller
- Collapse individual inactive-status test cases into test.each table
  for easier maintenance and extensibility
@PierreBrisorgueil
PierreBrisorgueil merged commit 6df1249 into master Mar 19, 2026
3 checks passed
@PierreBrisorgueil
PierreBrisorgueil deleted the fix/billing-quota-status-allowlist branch March 19, 2026 09:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(billing): requireQuota middleware should use active/trialing allowlist instead of past_due check

2 participants